package com.ipet.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ipet.order.mapper.OrderMapper;
import com.ipet.order.pojo.Order;
import com.ipet.order.service.OrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
@Transactional
public class OrderServiceImpl extends ServiceImpl<OrderMapper , Order> implements OrderService {
    @Override
    public PageInfo<Order> findAllOrder(Integer pageNo , Integer pageSize) {
        PageHelper.startPage(pageNo , pageSize);
        List<Order> orders = this.baseMapper.findallOrder();
        PageInfo<Order> orderPageInfo = new PageInfo<>(orders);
        return orderPageInfo;
    }

    @Override
    public PageInfo<Order> findOneById(Long orderId, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo , pageSize);
        List<Order> orderList = this.baseMapper.findOrderById(orderId);
        PageInfo<Order> orderPageInfo = new PageInfo<>(orderList);
        return orderPageInfo;
    }


}
